﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

using ImageRecognition2.Forms;

using LowLevelGraphics;
using LowLevelGraphics.Filter;
using LowLevelGraphics.Forms;

using FormConvolution = ImageRecognition2.Forms.FormConvolution;

namespace ImageRecognition2.Action
{
    /// <summary>
    /// Use this to run the convolution
    /// </summary>
    public class ActionConvolution : AbstractCommand
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public ActionConvolution()
        {
        }

        /// <summary>
        /// Runs the specified sender.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public override void Run(object sender, EventArgs e)
        {
            FormConvolution formConvolution = new FormConvolution();
            if (formConvolution.ShowDialog() == DialogResult.OK)
            {
                Bitmap bitmap = (Bitmap)MainFormSingleton.ActivePictureBox.BackgroundImage;
                UnsafeBitmap unsafeBitmap = new Convolution3x3(formConvolution.Matrix).Execute(bitmap);
                unsafeBitmap.Dispose();
            }
        }
    }
}
